/*****************************************************************************/
/**
 *  @file   SPHFileList.h
 *  @author Naohisa Sakamoto
 */
/*----------------------------------------------------------------------------
 *
 *  Copyright (c) Visualization Laboratory, Kyoto University.
 *  All rights reserved.
 *  See http://www.viz.media.kyoto-u.ac.jp/kvs/copyright/ for details.
 *
 *  $Id$
 */
/*****************************************************************************/
#pragma once

#include <kvs/Value>
#include <kvs/Vector3>
#include <kvs/FileList>
#include <iostream>
#include <vector>
#include <string>
#include "SPHFile.h"


namespace kvsbloodvis
{

namespace util
{

/*===========================================================================*/
/**
 *  @brief  SPH file list class.
 */
/*===========================================================================*/
class SPHFileList
{
private:

    std::vector<SPHFile> m_sph_list; ///< SPH file list
    kvs::Int32 m_sv_type; ///< field type (1:scalar, 2:vector)
    kvs::Int32 m_d_type; ///< data type (1:float, 2:double)
    kvs::Vector3d m_max; ///< number of voxels for each axis
    kvs::Vector3d m_org; ///< origin coordinate
    kvs::Vector3d m_pitch; ///< pitch of a voxel
    kvs::Int64 m_step; ///< time step
    kvs::Real64 m_time; ///< time
    bool m_header_only; ///< flag for reading header information

public:

    SPHFileList( const std::string& dirname, bool header_only = false );
    SPHFileList( const kvs::FileList& files, bool header_only = false );

    kvs::Int32 svType() const { return m_sv_type; }
    kvs::Int32 dType() const { return m_d_type; }
    kvs::Vector3d max() const { return m_max; }
    kvs::Vector3d org() const { return m_org; }
    kvs::Vector3d pitch() const { return m_pitch; }
    kvs::Int64 step() const { return m_step; }
    kvs::Real64 time() const { return m_time; }
    kvs::Vector3ui resolution() const { return kvs::Vector3ui( m_max.x(), m_max.y(), m_max.z() ); }
    kvs::UInt32 size() const { return m_sph_list.size(); }
    const SPHFile& sph( const size_t index ) const { return m_sph_list[index]; }
    void print( std::ostream& os, const kvs::Indent& indent = kvs::Indent(0) ) const;
    bool read( const std::string& dirname );
    bool read( const kvs::FileList& files );
};

} // end of namespace util

} // end of namespace kvsbloodvis
